<template>
  <div>Demo 页面</div>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  name: 'Demo',
  components: {

  },
  data() {
    return {

    }
  },
  computed: {
    // 使用对象展开运算符将 getter 混入 computed 对象中
    ...mapGetters([
      'list',
      'getListById'
    ])
  },
  async created() {
    console.log(this.list)
    console.log(this.getListById(1))

    this.$store.commit('demo/SET_LIST', [{ id: 4 }, { id: 5 }, { id: 6 }])
    console.log(this.list)
    console.log(this.getListById(1))

    await this.$store.dispatch('demo/setList')
    console.log(this.list)
    console.log(this.getListById(1))

    await this.$store.dispatch('user/handleLogin', {
      userName: 'super_admin'
    })
  },
  methods: {

  }
}
</script>
